package com.winsdom.controller;

import com.winsdom.anno.Authentication;
import com.winsdom.annotation.OperationLog;
import com.winsdom.vo.CustomerQueryVO;
import com.winsdom.service.CustomerService;
import com.winsdom.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

import static com.winsdom.enums.AuthenticationType.CUSTOMER_MANAGEMENT;

/**
 * 客户信息控制器
 * 用于管理客户的基本信息，包括查询客户列表、更新客户状态等操作
 * 支持客户信息的增删改查和状态管理
 */
@RestController
@RequestMapping("/customer")
@Api(tags = "客户管理接口", description = "客户基本信息管理接口")
@Authentication(value=CUSTOMER_MANAGEMENT)
public class CustomerController {

    @Autowired
    private CustomerService customerService;

    @GetMapping("/list")
    @ApiOperation(value = "查询客户列表", notes = "根据查询条件获取客户列表信息")
    @OperationLog(description = "查询客户列表")
    public Result<Map<String, Object>> queryCustomers(CustomerQueryVO query) {
        Map<String, Object> result = customerService.queryCustomers(query);
        return Result.success(result);
    }

    @GetMapping("/updateLegalProcedure/{customerId}")
    @ApiOperation(value = "更新客户涉诉状态", notes = "更新指定客户的涉诉状态信息")
    @OperationLog(description = "更新客户涉诉状态")
    public Result<Map<String, Object>> updateLegalProcedure(@PathVariable Long customerId) {
        Map<String, Object> result = customerService.updateLegalProcedure(customerId);
        return Result.success(result);
    }
    
    @GetMapping("/updateStatus/{customerId}")
    @ApiOperation(value = "更新客户状态", notes = "更新指定客户的状态信息")
    @OperationLog(description = "更新客户状态")
    public Result<Map<String, Object>> updateCustomerStatus(@PathVariable Long customerId) {
        Map<String, Object> result = customerService.updateCustomerStatus(customerId);
        return Result.success(result);
    }
}